// 防抖 不立即执行函数 等待一段时间后执行函数
export default (fn: Function, delay: number) => {
  let timer: number | null = null;
  return () => {
    if (timer) {
      clearTimeout(timer);
      timer = setTimeout(fn, delay);
    } else {
      timer = setTimeout(fn, delay);
    }
  };
};
